using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.Web.BL.Authentication;

public partial class admin_webparts_Plug_ins_User2_UserSearch : System.Web.UI.UserControl
{
    public int _ResultTotal = -1;
    public User _User = null;
    public DataTable _SearchResult = null;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void btnSearch_Click(object sender, EventArgs e)
    {
        string phone = txtPhoneNumber.Text.Trim();
        string email = txtEmail.Text.Trim();
        string username = txtUsername.Text.Trim();
        try
        {
            if (username.Length > 0)
            {
                _ResultTotal = 0;
                User user = new User(username);
                if (user.ID > 0)
                {
                    _User = user;
                    _ResultTotal = 1;
                }
            }
            else if (email.Length > 0 || phone.Length > 0)
            {
                _SearchResult = User.Search(email, phone);
                _ResultTotal = _SearchResult == null ? 0 : _SearchResult.Rows.Count;
            }
            //else if (phone.Length > 0)
            //{
            //    _SearchResult = User.Search(phone);
            //    _ResultTotal = _SearchResult == null ? 0 : _SearchResult.Rows.Count;
            //}
            //else if (postID.Length > 0)
            //{
            //    _ResultTotal = 0;
            //    PendingPost post = new PendingPost(Convert.ToInt32(postID));
            //    if (post.ID > 0)
            //    {
            //        User user = new User(post.UserID);
            //        if (user.ID > 0)
            //        {
            //            _User = user;
            //            _ResultTotal = 1;
            //        }
            //    }
            //}
            //else if (billID.Length > 0)
            //{
            //    _ResultTotal = 0;
            //    PostBill bill = new PostBill(Convert.ToInt32(billID));
            //    if (bill.ID > 0)
            //    {
            //        PendingPost post = new PendingPost(bill.PostID);
            //        if (post.ID > 0)
            //        {
            //            User user = new User(post.UserID);
            //            if (user.ID > 0)
            //            {
            //                _User = user;
            //                _ResultTotal = 1;
            //            }
            //        }
            //    }
            //}
            else
            {
                _ResultTotal = -1;
            }
            //if (_ResultTotal > -1)
            //{
            //    _ResultTotal = _SearchResult == null ? 0 : _SearchResult.Rows.Count;
            //}
        }
        catch { }
    }
}
